package com.dg11185.nearshop.net.request;

import com.dg11185.libs.utils.MD5.MD5Utils;
import com.dg11185.nearshop.app.Constants;
import com.dg11185.nearshop.net.HttpCacheRequest;
import com.dg11185.nearshop.net.response.GetFavorListResponse;

public class GetFavorListRequest extends HttpCacheRequest<GetFavorListResponse> {

    public GetFavorListRequest(String userId) {
        super(Constants.ADDRESS, Constants.getFavorList);
        addParam("userId", userId);
        addParam("chshToken", Constants.TOKEN);
        setIsCreateFloder(true);
    }

    /**
     * <可选参数> <param name="type">类型</param> <param
     * name="pageNumber">当前页码</param> <param name="pageSize">每页数量</param> <param
     * name="orderName">排序字段</param> <param name="orderType">0.升序，1.降序</param>
     * </可选参数>
     */
    public GetFavorListRequest add(String key, String value) {
        addParam(key, value);
        return this;
    }

    public GetFavorListRequest encryption() {
        addParam("chshSign", MD5Utils.getMD5Str(getParams(), Constants.MD5_key));
        return this;
    }

    @Override
    protected GetFavorListResponse parseJson(String response) throws Exception {
        GetFavorListResponse r = new GetFavorListResponse();
        r.parseJson(response);
        return r;
    }

}
